﻿using BusinessLogic;
using Ch.Elca.Iiop;
using Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Text;
using System.Windows.Forms;

namespace QlpmServer
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
            InitServer(6969);

        }

        private void InitServer(int port)
        {
            //Initialize channel
            IiopChannel iiopChannel = new IiopChannel(port);
            ChannelServices.RegisterChannel(iiopChannel, false);

            WorkerBL remoteWorker = new WorkerBL();
            string workerURI = "WorkerBL";
            PatientBL remotePatient = new PatientBL();
            string patientURI = "PatientBL";
            MedicineBL remoteMedicine = new MedicineBL();
            string medURI = "MedicineBL";
            MyQueryBL remoteMyQuery = new MyQueryBL();
            string myQueryBLURI = "MyQueryBL";
			PositionBL remotePos = new PositionBL();
            string positionBLURI = "PositionBL";
            TreatmentBL remoteTre = new TreatmentBL();
            string treatmentBLURI = "TreatmentBL";
            PrescriptionBL remotePre = new PrescriptionBL();
            string preBLURI = "PrescriptionBL";
            RemotingServices.Marshal(remotePatient, patientURI);
            RemotingServices.Marshal(remoteWorker, workerURI);
            RemotingServices.Marshal(remoteMedicine, medURI);
            RemotingServices.Marshal(remoteMyQuery, myQueryBLURI);
            RemotingServices.Marshal(remotePos, positionBLURI);
            RemotingServices.Marshal(remoteTre, treatmentBLURI);
            RemotingServices.Marshal(remotePre, preBLURI);
            label1.Text = "Running";
        }

        private void MainForm_Load(object sender, EventArgs e)
        {

        }
    }
}
